//
//  TIMMessage.h
//  TIMLib
//
//  Created by Deli Xia on 2018/5/22.
//  Copyright © 2018年 Deli Xia. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "TIMStorageModel.h"
#import "TIMCommon.h"

typedef NS_ENUM(NSInteger, TIMMessageType) {
    TIMMessageTypeUnknown,
    TIMMessageTypeText,          // 文字
    TIMMessageTypeImage,         // 图片
    TIMMessageTypeExpression,    // 表情
    TIMMessageTypeVoice,         // 语音
    TIMMessageTypeVideo,         // 视频
    TIMMessageTypeURL,           // 链接
    TIMMessageTypePosition,      // 位置
    TIMMessageTypeBusinessCard,  // 名片
    TIMMessageTypeSystem,        // 系统
    TIMMessageTypeOther,         // 界面不展示
    
    TIMMessageTypeSnapshotText = 33, // 阅后即焚文本
    TIMMessageTypeSnapshotPhoto = 43, // 阅后即焚图片
    TIMMessageTypeSnapshotVoice = 44, // 阅后即焚语音
    TIMMessageTypeSnapshotVideo = 45, // 阅后即焚视频
    TIMMessageTypeSnapshotExpression = 46, // 阅后即焚表情
    
    TIMMessageTypeCustom =  101,    // 自定义
    TIMMessageTypeFile   =  102,    // 文件
    TIMMessageTypeGift   =  103,    // 打赏
};

/**
 *  消息所有者类型
 */
typedef NS_ENUM(NSInteger, TIMPartnerType){
    TIMPartnerTypeUser,          // 用户
    TIMPartnerTypeGroup,         // 群聊
};

/**
 *  消息拥有者
 */
typedef NS_ENUM(NSInteger, TIMMessageOwnerType){
    TIMMessageOwnerTypeUnknown,  // 未知的消息拥有者
    TIMMessageOwnerTypeSystem,   // 系统消息
    TIMMessageOwnerTypeSelf,     // 自己发送的消息
    TIMMessageOwnerTypeFriend,   // 接收到的他人消息
};

/**
 *  消息发送状态
 */
typedef NS_ENUM(NSInteger, TIMMessageSendState){
    TIMMessageSending,       // 正在发送
    TIMMessageSendSuccess,       // 消息发送成功
    TIMMessageSendFail,          // 消息发送失败
};

/**
 *  消息读取状态
 */
typedef NS_ENUM(NSInteger, TIMMessageReadState) {
    TIMMessageUnRead,            // 消息未读
    TIMMessageReaded,            // 消息已读
};

/**
 *  接受者类型
 */
typedef NS_ENUM(NSInteger, TIMMessageReviceState) {
    TIMMessageRevicePerson,            // 好友
    TIMMessageReviceGroup,            // 群组
};

/**
 *  消息是否点击过
 */
typedef NS_ENUM(NSInteger, TIMMessageClickState) {
    TIMMessageUnClick,            // 消息未点击
    TIMMessageDidClick,            // 消息已点击
};

/**
 *  语音消息是否点击过
 */
typedef NS_ENUM(NSInteger, TIMVoiceMessageStatus) {
    TIMVoiceMessageStatusNormal,
    TIMVoiceMessageStatusRecording,
    TIMVoiceMessageStatusPlaying,
};

@class TIMMessageFrame;
@class TIMEmojiContent;
@interface TIMMessage : NSObject<NSCopying>

@property (nonatomic, strong) NSString *messageID;                  // 消息ID
@property (nonatomic, strong) NSString *friendID;                   // 接收者ID
@property (nonatomic, strong) NSString *groupID;                    // 讨论组ID（无则为nil）
@property (nonatomic, strong) TIMUserInfo *fromUser;               // 发送者
@property (nonatomic, assign, readonly) NSInteger msgKey;                    // msgKey
@property (nonatomic, assign, readonly) NSInteger globalID;                    // 会话列表记录ID
@property (nonatomic, strong) NSDate *date;                         // 发送时间

@property (nonatomic, assign) BOOL showTime;
@property (nonatomic, assign) BOOL showName;

@property (nonatomic, assign) TIMPartnerType partnerType;            // 对方类型
@property (nonatomic, assign) TIMMessageType messageType;            // 消息类型
@property (nonatomic, assign) TIMMessageReadState readState;         // 读取状态
@property (nonatomic, assign) TIMMessageOwnerType ownerTyper;        // 发送者类型
@property (nonatomic, assign) TIMMessageSendState sendState;         // 发送状态
@property (nonatomic, assign) TIMMessageReviceState reviceState;     // 接受者类型
@property (nonatomic, assign) TIMMessageClickState clickState;       // 是否点击过   判断语音点击 跟 以后的阅后即焚功能
@property (nonatomic, assign) TIMOperateGroupType operateGroupType;         // 新增OP
@property (nonatomic, strong) NSString *isAateMessage;               // 是否为@消息
@property (nonatomic, strong) NSString *snapshotTime;               // 阅后即焚时间

@property (nonatomic, strong) NSString *text;           // 文字信息，表情文字信息

// 图片
@property (nonatomic, strong) NSString *imagePath;      // 存放图片本地的URL
@property (nonatomic, assign) CGSize imageSize;

// 语音
@property (nonatomic, assign) CGFloat voiceTime;
@property (nonatomic, strong) NSString *voicePath;      // 存放语音本地URL
@property (nonatomic, assign) TIMVoiceMessageStatus voiceMessageStatus;

// 表情
@property (nonatomic, copy) NSAttributedString *expressionText;       // 表情
@property (nonatomic, strong) TIMEmojiContent *emoji;   // 表情加载包

@property (nonatomic, strong) NSString *url;            // 图片，语音，远程url
@property (nonatomic, strong) TIMMessageFrame *messageFrame;      // 消息大小

// 界面上显示
@property (nonatomic, strong) NSArray *showUserArray;


- (NSString *)conversationContent;

- (void)resetMessageFrame;

@end

@interface TIMMessageFrame : NSObject

@property (nonatomic, assign) CGFloat height;
@property (nonatomic, assign) CGSize contentSize;

@end

@interface TIMEmojiContent : NSObject

@property (nonatomic, strong) NSString *groupID;
@property (nonatomic, strong) NSString *emojiID;
@property (nonatomic, strong) NSString *emojiURL;
@property (nonatomic, strong) NSString *emojiPath;
@property (nonatomic, strong) NSString *emojiName;
@property (nonatomic, assign) CGSize emojiSize;

@end

@interface TIMCommentMessage : NSString

@property (nonatomic, assign) TIMMessageType messageType;
@property (nonatomic, copy) NSString *nickName;
@property (nonatomic, copy) NSString *content;
@property (nonatomic, copy) NSString *senderId;
@property (nonatomic, copy) NSString *groupID;

@end



